import requests
import json
#接收用户输入的城市名称
city_name = input("请输入查询的城市: (汉字) ")
#将API接口拼接完整
url = 'https://www.tianqiapi.com/api/?version=v6&appid=74169348&appsecret=ti3VzXtb&city'+city_name
#访问天气接口获得完整数据
response = requests.get(url)
#获得返回的城市天气的json数据
json_data = response.text
#将json数据转为Python字典
weather_dict = json.loads(json_data)
#取出字典中的天气信息，使用print进行展示
print("当前位置: " + weather_dict['city'])
print("今天是: " + weather_dict['date'] + weather_dict['week'])
print("当前温度: "+ weather_dict['tem'] + '°C')
print("当前天气: " + weather_dict['wea'])
print("风速: " + weather_dict['win_speed'])
print("风力: " + weather_dict['win_meter'])
print("空气质量: " + weather_dict['air_level'])
print("建议: " + weather_dict['air_tips'])